package com.oilsection.demo.controller;

import com.alibaba.fastjson.JSON;
import com.oilsection.demo.controller.res.JcEventStatisticsDataDto;
import com.oilsection.demo.po.JcEventInfoTable;
import com.oilsection.demo.po.JcdInfoTable;
import com.oilsection.demo.po.JzInfoTable;
import com.oilsection.demo.po.KqInfoTable;
import com.oilsection.demo.entity.*;
import com.oilsection.demo.mutipleImportDo.JcEventMiDo;
import com.oilsection.demo.mutipleImportDo.JcdMiDo;
import com.oilsection.demo.mutipleImportDo.JzMiDo;
import com.oilsection.demo.service.DataManagerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author yangyuge
 * @description
 * @Date 2024/5/3 16:08
 */
@Slf4j
@RestController
public class DataManagerController {

    @Resource
    private DataManagerService dataManagerService;

    @CrossOrigin
    @GetMapping("/getDMkqJcdEventInfo")
    public dmJceventInfo getDMkqJcdEventInfo(String jcEventId, String kqName, String jzId, String jzName, String jcType, String jcdId, String jcdName, @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date jcTime, String updateTime, String szjType, int page, int pageSize) {
        return dataManagerService.getDMkqJcdEventInfo(jcEventId, kqName, jzId, jzName, jcType, jcdId, jcdName, jcTime, updateTime, szjType, page, pageSize);
    }

    @CrossOrigin
    @GetMapping("/getDMkqJcdStatisticsDataByJcdId/{jcdId}")
    public List<JcEventStatisticsDataDto> getDMkqJcdStatisticsDataByJcdId(@PathVariable String jcdId) {
        return dataManagerService.getDMkqJcdStatisticsDataByJcdId(jcdId);
    }
    
    @CrossOrigin
    @GetMapping("/getDMkqJcdInfo")
    public dmJcdInfo getDMkqJcdInfo(String kqName, String jzId, String jzName, String jcdId, String updateTime, String jcdName, int page, int pageSize) {
        return dataManagerService.getDMkqJcdInfo(kqName, jzId, jzName, jcdId, updateTime, jcdName, page, pageSize);
    }
    
    @CrossOrigin
    @GetMapping("/getDMKqJzInfo")
    public dmJzInfo getDMKqJzInfo(String kqName, String jzId, String jzState, String jzName, int page, int pageSize) {
        return dataManagerService.getDMKqJzInfo(kqName, jzId, jzState, jzName, page, pageSize);
    }
    
    @CrossOrigin
    @GetMapping("/getDMkqkqInfo")
    public dmKqInfo getDMkqkqInfo(String kqId, String kqName, String kqState, String kqArea, String startTime, int page, int pageSize) {
        return dataManagerService.getDMkqkqInfo(kqId, kqName, kqState, kqArea, startTime, page, pageSize);
    }
    
    @GetMapping("/addOneKqInfo")
    public KqInfoTable addOneKqInfo(String kqName, String kqId, String kqState, String kqArea, String startTime) {
        return dataManagerService.addOneKqInfo(kqName, kqId, kqState, kqArea, startTime);
    }
    
    @CrossOrigin
    @GetMapping("/addOneJcdInfo")
    public JcdInfoTable addOneJcdInfo(String kqId, String jzId, String jcdId, String jcdXpoint, String jcdYpoint, String updateTime,String jcdName) {
        return dataManagerService.addOneJcdInfo(kqId, jzId, jcdId, jcdXpoint, jcdYpoint, updateTime,jcdName);
    }
    
    @CrossOrigin
    @GetMapping("/addOneJzInfo")
    public JzInfoTable addOneJzInfo(String kqId, String jzId, String jzName, String jzState, String jzArea, String updateTime, String jcdNum, String jkXpoint, String jkYpoint, String szj1, String szj2, String szj3) {
        return dataManagerService.addOneJzInfo(kqId, jzId, jzName, jzState, jzArea, updateTime, jcdNum, jkXpoint, jkYpoint, szj1, szj2, szj3);
    }
    
    @CrossOrigin
    @GetMapping("/addOneJcEventInfo")
    public JcEventInfoTable addOneJcEventInfo(String kqId, String jzId, String jcEventId, String jcValue, String jcXpoint, String jcYpoint, String jcType, String updateTime, String jcdId, String szjType) {
        return dataManagerService.addOneJcEventInfo(kqId, jzId, jcEventId, jcValue, jcXpoint, jcYpoint, jcType, updateTime, jcdId, szjType);
    }
    
    @CrossOrigin
    @GetMapping("/updateOneKqInfo")
    public KqInfoTable updateOneKqInfo(String kqId, String kqArea) {
        return dataManagerService.updateOneKqInfo(kqId, kqArea);
    }
    
    @CrossOrigin
    @GetMapping("/updateOneJzInfo")
    public JzInfoTable updateOneJzInfo(String jzId, String jzArea, String jkXpoint, String jkYpoint, String szj1, String szj2, String szj3) {
        return dataManagerService.updateOneJzInfo(jzId, jzArea, jkXpoint, jkYpoint, szj1, szj2, szj3);
    }
    
    @CrossOrigin
    @GetMapping("/updateOneJcdInfo")
    public JcdInfoTable updateOneJcdInfo(String jcdId, String jcXpoint, String jcYpoint) {
        return dataManagerService.updateOneJcdInfo(jcdId, jcXpoint, jcYpoint);
    }
    
    @CrossOrigin
    @GetMapping("/updateOneJcEventInfo")
    public JcEventInfoTable updateOneJcEventInfo(String jcEventId, String jcTime, String szjType, String jcValue) {
        return dataManagerService.updateOneJcEventInfo(jcEventId, jcTime, szjType, jcValue);
    }
    
    @CrossOrigin
    @PostMapping("/mutipleImportKqInfo")
    public Boolean mutipleImportKqInfo(@RequestBody Map<String, Object> map) {
        Object kqList = map.get("kqList");
        List<addKqInfo> node = JSON.parseArray(kqList.toString(), addKqInfo.class);
        return dataManagerService.mutipleImportKqInfo(node);
    }
    
    @CrossOrigin
    @GetMapping("/deleteOneKqInfo")
    public int deleteOneKqInfo(String kqId) {
        return dataManagerService.deleteOneKqInfo(kqId);
    }
    
    @CrossOrigin
    @GetMapping("/deleteOneJzInfo")
    public int deleteOneJzInfo(String jzId) {
        return dataManagerService.deleteOneJzInfo(jzId);
    }
    
    @CrossOrigin
    @GetMapping("/deleteOneJcdInfo")
    public int deleteOneJcdInfo(String jcdId) {
        return dataManagerService.deleteOneJcdInfo(jcdId);
    }
    
    @CrossOrigin
    @GetMapping("/deleteOneJcEventInfo")
    public int deleteOneJcEventInfo(String jcEventId) {
        return dataManagerService.deleteOneJcEventInfo(jcEventId);
    }

    @CrossOrigin
    @PostMapping("/mutipleImportJcEventInfo")
    public Boolean mutipleImportJcEventInfo(@RequestBody Map<String, Object> map) {
        Object jcEventList = map.get("jcEventList");
        List<JcEventMiDo> node = JSON.parseArray(jcEventList.toString(), JcEventMiDo.class);
        return dataManagerService.mutipleImportJcEventInfo(node);
    }

    @CrossOrigin
    @PostMapping("/mutipleImportJcdInfo")
    public Boolean mutipleImportJcdInfo(@RequestBody Map<String, Object> map) {
        Object jcdList = map.get("jcdList");
        List<JcdMiDo> node = JSON.parseArray(jcdList.toString(), JcdMiDo.class);
        return dataManagerService.mutipleImportJcdInfo(node);
    }

    @CrossOrigin
    @PostMapping("/mutipleImportJzInfo")
    public Boolean mutipleImportJzInfo(@RequestBody Map<String, Object> map) {
        Object jzList = map.get("jzList");
        List<JzMiDo> node = JSON.parseArray(jzList.toString(), JzMiDo.class);
        return dataManagerService.mutipleImportJzInfo(node);
    }

}
